package cn.javass.dp.memento.example4;


public class Client {
    public static void main(String[] args) {
        OperationApi operation = new Operation();

        AddCommand addCmd  = new AddCommand(5);
        SubstractCommand substractCommand = new SubstractCommand(2);

        addCmd.setOperation(operation);
        substractCommand.setOperation(operation);
        Calculator cal = new Calculator();
        //+5  =5
        cal.setAddCmd(addCmd);
        cal.addPressed();
        System.out.println(operation.getResult());

        //-2   =3
        cal.setSubstractCmd(substractCommand);
        cal.substractPressed();
        System.out.println(operation.getResult());

        //撤销  5
        cal.undoPressed();
        System.out.println(operation.getResult());

        //恢复操作
        cal.redoPressed();
        System.out.println(operation.getResult());
    }
}
